<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // setTimeout(() => {
        //     console.log('1') // 3. 1
        // })
        // console.log('2') // 1. 2
        // new Promise(() => {
        //     console.log('3') // 2. 3
        // })
       var arr = [1, 2 , 5, 6, 2]
       for(var i=0; i<arr.length; i++) {
           for (var j = i+1; j< arr.length; j++) {
               if (arr[i] === arr[j]) {
                  arr.splice(j,1);
               }
           }
       }
       console.log(arr)

       var arr1 = [1, 4, 6, 4]
       console.log(Array.from(new Set(arr1)))

       function unique(arr) {
            var array = []
            for (var i =0; i< arr.length; i++) {
                if (array.indexOf(arr[i]) === -1) {
                    array.push(arr[i])
                }
            }
            return array
      }
    var arr3 = [1, 2, 3, 2];
    console.log(unique(arr3))

    function unique1(arr) {
            var array = []
            for (var i =0; i< arr.length; i++) {
                if (!array.includes(arr[i])) {
                    array.push(arr[i])
                }
            }
            return array
      }
    var arr4 = [1, 2, 3, 2, 6];
    console.log(unique1(arr4))
    console.log([...new Set([1, 4, 2, 4, 5])])
   // [1, "true", true, 15, false, undefined, null, NaN, NaN, "NaN", 0, "a", {…}, {…}]  //NaN、{}没有去重
    </script>
</body>
</html>